package com.ning.farm_income_back.controller;

import com.github.pagehelper.PageInfo;
import com.ning.farm_income_back.domain.Feedback;
import com.ning.farm_income_back.dto.FeedbackDto;
import com.ning.farm_income_back.service.FeedbackService;
import com.ning.farm_income_back.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;

    //分页带条件查询
    @PostMapping("/page")
    public ResultVo<PageInfo> page(@RequestBody FeedbackDto feedback, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam Integer pageSize ) {
        //获取页面数据
        PageInfo pageInfo = feedbackService.getPage(feedback,pageNum,pageSize);

        return ResultVo.success("查询成功",pageInfo);
    }

    //管理员更新反馈
    @PutMapping("/updateFeedback")
    public ResultVo updateFeedback(@RequestBody Feedback feedback) {

        feedbackService.updateFeedback(feedback);
        return ResultVo.success("反馈成功");
    }

    //用户提交反馈
    @PostMapping("/addContent")
    public ResultVo addContent(@RequestBody Feedback feedback) {
        feedbackService.addContent(feedback);
        return ResultVo.success("提交成功");
    }
}
